package miiteen.customsportal.basic.service;

import miiteen.hr.pubconfig.CurrentHrInfo;
import miiteen.hr.user.beans.UserUserInfo;
import miiteen.sys.login.bean.UserShiro;
import miiteen.sys.login.utils.LoginUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import miiteen.data.dao.BaseDao;
import miiteen.data.service.impl.BaseServiceImpl;

import miiteen.customsportal.basic.beans.BasicNavigation;
import miiteen.customsportal.basic.dao.BasicNavigationDao;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * Name: CustomsPortal_ Basic_Navigation
 * Des: -Service
 * Author: yulp
 * Date: 2020-07-03
 */
@Service(" BasicNavigationService")
public class BasicNavigationService extends BaseServiceImpl<BasicNavigation> {

    @Autowired
    private BasicNavigationDao basicNavigationDao;

    @Override
    protected BaseDao<BasicNavigation> getDao() {
        return basicNavigationDao;
    }


    @Transactional
    public long save(BasicNavigation basicNavigation){
        UserShiro.ShiroUser shiroUser= LoginUtil.getCurUser();
        UserUserInfo userInfo= CurrentHrInfo.getUserInfo(shiroUser);

        if(basicNavigation.getId()>0){
            //修改
            basicNavigation.setUpdateId(userInfo.getId());//修改人id
            basicNavigation.setUpdateTime(new Date());//修改时间
            basicNavigation.setUpdator(userInfo.getTrueName());//修改人名
        }else{
            //保存
            basicNavigation.setOrganizeId(2001);//组织id
            basicNavigation.setCreateId(userInfo.getId());//创建人id
            basicNavigation.setCreateTime(new Date());//创建时间
            basicNavigation.setCreator(userInfo.getTrueName());//创建人名
        }

        return basicNavigationDao.save(basicNavigation);
    }

}
